<template>
  <div
    v-if="types==='list'"
    class="product-status"
  >
    <div
      v-if="datas.priceStrategyStatus==='1'"
      class="status"
    >
      <div>{{ getLabel('product_price_status',datas.priceStrategyStatus) }}</div>
      <div
        v-if="datas.flowStatus!=='AGREE'&&datas.flowStatus!=='REFUSE'&&types==='list'"
        class="flow-status-color"
      >
        <div v-if="datas.flowStatus==='DOING'">
          <span v-if="datas.processDefinitionKey==='productPriceChange'">[变更审核中]</span>
          <span v-if="datas.processDefinitionKey==='productPriceBan'">[作废审核中]</span>
        </div>
      </div>
    </div>
    <div
      v-if="datas.priceStrategyStatus==='-1'"
      class="status"
    >
      <span>{{ getLabel('approval_result',datas.flowStatus) }}</span>
    </div>
    <div
      v-else-if="datas.priceStrategyStatus==='-2'"
      class="status"
    >{{ getLabel('product_price_status',datas.priceStrategyStatus) }}</div>
  </div>
  <el-tag
    v-else
    type="warning"
    size="small"
  >
    <div
      v-if="datas.priceStrategyStatus==='1'"
      style="display:flex;align-items:center;"
    >
      <div>{{ getLabel('product_price_status',datas.priceStrategyStatus) }}</div>
      <div
        v-if="datas.flowStatus!=='AGREE'&&datas.flowStatus!=='REFUSE'"
        style="margin-left:4px;"
      >
        <div v-if="datas.flowStatus==='DOING'">
          <span v-if="datas.processDefinitionKey==='productPriceChange'">[变更审核中]</span>
          <span v-if="datas.processDefinitionKey==='productPriceBan'">[作废审核中]</span>
        </div>
      </div>
    </div>
    <div
      v-if="datas.priceStrategyStatus==='-1'"
      class="status"
    >
      <span>{{ getLabel('approval_result',datas.flowStatus) }}</span>
    </div>
    <div
      v-else-if="datas.priceStrategyStatus==='-2'"
      class="status"
    >{{ getLabel('product_price_status',datas.priceStrategyStatus) }}</div>
  </el-tag>
</template>

<script>
import {computed, defineComponent, reactive, toRefs} from 'vue'

export default defineComponent({
  props: {
    datas: {
      type: Object,
      default: () => {
        return {
          priceStrategyStatus: -1,
          flowStatus: '',
        }
      },
    },
    types: {
      type: String,
      default: 'list',
    },
  },
  setup(props, context) {
    var reactiveData = reactive({
      tagType: '',
    })
    reactiveData.tagType = computed(() => {
      var types = ''
      if (props.datas.flowStatus === 'DOING') {
        types = 'warning'
      } else {
        if (props.datas.priceStrategyStatus === '-1') {
          types = 'error'
        } else if (props.datas.priceStrategyStatus === '1') {
          types = 'success'
        }
      }
      return types
    })
    return {
      ...toRefs(props),
      ...toRefs(reactiveData),
    }
  },
})
</script>

